package com.logicalthinking.socialmall.controller.admin;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.annos.PropertyCheck;
import com.logicalthinking.socialmall.biz.AdminBiz;
import com.logicalthinking.socialmall.common.vo.requestVo.admin.*;
import com.logicalthinking.socialmall.common.vo.responseVo.admin.AdminVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 管理员用户
 *
 * @author chenLiJia
 * @since 2020-02-17 14:43:59
 **/
@RestController
@RequestMapping(value = "admin/admin")
@Api(tags = "管理员用户")
@PropertyCheck
public class AdminController {


    @Autowired
    private AdminBiz adminBiz;//管理员用户

    /**
     * 添加用户
     *
     * @param params
     * @return
     */
    @PostMapping(value = "add")
    @ApiOperation(value = "添加用户")
    public Result add(AdminAddParams params) {
        return adminBiz.add(params);
    }

    /**
     * 删除用户
     *
     * @param id
     * @return
     */
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除用户")
    public Result delete(Integer id) {
        return adminBiz.delete(id);
    }

    /**
     * 批量删除用户
     *
     * @param idList
     * @return
     */
    @PostMapping(value = "delete/batch")
    @ApiOperation(value = "批量删除用户")
    public Result batchDelete(List<Integer> idList) {
        return adminBiz.batchDelete(idList);
    }

    /**
     * 修改用户信息
     *
     * @param params
     * @return
     */
    @PostMapping(value = "update")
    @ApiOperation(value = "修改用户信息")
    public Result update(AdminUpdateParams params) {
        return adminBiz.update(params);
    }

    /**
     * 主键查询用户信息
     *
     * @param id
     * @return
     */
    @PostMapping(value = "findById")
    @ApiOperation(value = "主键查询用户信息", response = AdminVo.class)
    public Result findById(Integer id) {
        return adminBiz.findById(id);
    }

    /**
     * 列表查询用户信息
     *
     * @param params
     * @return
     */
    @PostMapping(value = "listPage")
    @ApiOperation(value = "列表查询用户信息", response = AdminVo.class)
    public Result listPage(AdminListQueryParams params) {
        return adminBiz.listPage(params);
    }

    /**
     * 重置密码
     *
     * @param id
     * @return
     */
    @PostMapping(value = "password/reset")
    @ApiOperation(value = "重置密码")
    public Result resetPassword(Integer id) {
        return adminBiz.resetPassword(id);
    }

    /**
     * 修改密码
     *
     * @param params
     * @return
     */
    @PostMapping(value = "password/update")
    @ApiOperation(value = "修改密码")
    public Result updatePassword(ResetPasswordParams params) {
        return adminBiz.updatePassword(params);
    }

    /**
     * 启用
     *
     * @param id
     * @return
     */
    @PostMapping(value = "enable")
    @ApiOperation(value = "启用")
    public Result enable(Integer id) {
        return adminBiz.enable(id);
    }

    /**
     * 批量启用
     *
     * @param idList
     * @return
     */
    @PostMapping(value = "enable/batch")
    @ApiOperation(value = "批量启用")
    public Result batchEnable(List<Integer> idList) {
        return adminBiz.batchEnable(idList);
    }

    /**
     * 禁用
     *
     * @param id
     * @return
     */
    @PostMapping(value = "disable")
    @ApiOperation(value = "禁用")
    public Result disable(Integer id) {
        return adminBiz.disable(id);
    }

    /**
     * 批量禁用
     *
     * @param idList
     * @return
     */
    @PostMapping(value = "disable/batch")
    @ApiOperation(value = "批量禁用")
    public Result batchDisable(List<Integer> idList) {
        return adminBiz.batchDisable(idList);
    }

    /**
     * 登陆
     *
     * @param params
     * @return
     */
    @PostMapping(value = "login")
    @ApiOperation(value = "登陆", notes = "token在response的header中")
    public Result login(LoginParams params) {
        return adminBiz.login(params);
    }

}
